import React, { useContext } from 'react';
import MyContext from './MyContext';
const InputView = () => {
  let { list, setList } = useContext(MyContext)
  // console.log(list) // 先观察Provider提供的数据的格式，在使用数据
  const sendMsg = () => {
    // list.push({ id: 2, msg: '12313', date: '2022-12-12' })
    setList([...list, { id: 2, msg: '12313', date: '2022-12-12' }])
    console.log(list)
  }
  return (
    <div>
      <div>
        <input type="text" placeholder='请留言' />
        <button type='button' onClick={sendMsg}>发贴</button>
      </div>
    </div>
  );
}

export default InputView;
